using System;

namespace Jv.Games.Engine
{
	public class Game: IDisposable
	{
		#region Attributes
		XnaGame InternalGame { get; set; }
		#endregion

		#region Constructors
		public Game(Level firstLevel)
		{
			InternalGame = new XnaGame();
			ChangeLevel(firstLevel);
		}
		#endregion

		#region Public Methods
		public void Play()
		{
			InternalGame.Run();
		}
		#endregion

		#region Internal Methods
		internal void ChangeLevel(Level nextLevel)
		{
			if(nextLevel != null)
				nextLevel.CurrentGame = this;
			InternalGame.CurrentLevel = nextLevel;
		}
		#endregion

		#region Implementation of IDisposable
		/// <summary>
		/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		public void Dispose()
		{
			InternalGame.Dispose();
		}
		#endregion
	}
}
